package com.cevent.community.app.business.exception;/**
 * Created by Cevent on 2021/9/14.
 */

import com.cevent.community.app.common.dto.ResponseDataDto;
import com.cevent.community.app.common.exception.ValidatorException;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * @author cevent
 * @description 统一异常捕获
 * @date 2021/9/14 17:14
 */
@ControllerAdvice
public class ControllerException {
    @ExceptionHandler(value= ValidatorException.class)
    @ResponseBody
    public ResponseDataDto validatorExceptionHandler(ValidatorException validatorException){
        ResponseDataDto responseData=new ResponseDataDto();
        responseData.setSuccess(false);
        responseData.setResponseMsg(validatorException.getMessage());
        return responseData;
    }
}
